package sd.zhr.moodcapsule.configure;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

public class FileHandlerConfig extends WebMvcConfigurationSupport {
    @Value("${upload.path}")
    private String parentDir;
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        //registry.addResourceHandler("/upload/**").addResourceLocations("File:"+System.getProperty("user.dir")+"/upload/");
        registry.addResourceHandler("/upload/**").addResourceLocations("File:"+parentDir+"upload/");
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
    }
}
